package com.spring.utils.api_v4.pojo.salary.task;

import com.spring.utils.api_v4.pojo.DeptInfo;
import com.spring.utils.api_v4.pojo.salary.DeptWage;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.java.Log;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 部门工资任务
 */
@Entity
@Table(name = "tb_dept_wage_task")
@Getter
@Setter
@Log
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
public class DeptWageTask implements Serializable {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @Column(length = 32)
    private String id;
    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "task_id", nullable = false)
    private WageTask task;  // 所属任务
    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "dept_id", nullable = false)
    private DeptWage dept;  // 所属部门
    @Column(nullable = false)
    private double meritPay = 0; // 历史余额
    @Column(nullable = false)
    private double totalMerit = 0;  // 绩效总额
    @Column(nullable = false)
    private double disMerit = 0;    // 已分配绩效
    @Column(nullable = false)
    private int state = 0;  // 状态 0:初始 1:设置中 2:已完成 -1:锁定

    private String note = "无特殊说明";    // 说明

    // 员工工资列表
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "task")
    private List<EmployeeSalaryTask> salaryList;    // 员工工资列表
}
